package xml_parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import database.Operation;



public class Component {
	private String id;
	private String idref;
	private String name;
	private String type;
	private ArrayList<Association> relationship ;
	
	private HashMap<String, ArrayList<Operation>> operationList;
	
	public Component(){
		relationship=new ArrayList<Association>();
		operationList=new HashMap<String, ArrayList<Operation>>();
	}


	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public ArrayList<Association> getRelationship() {
		return relationship;
	}
	
	public void addRelationship(Association rel) {
		if(rel==null){
			System.out.println(getName()+" addRel NULL");
		}
		else{
			relationship.add(rel);
		}
	}
	
	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}
	
	public String toString() {
		if(relationship!=null)
			for(Association a:relationship){
				System.out.println(getName()+" | rel with :" + a.getParticipant());
			}
		else
			System.out.println(getName()+" | rel null");
		StringBuffer sb = new StringBuffer();
		sb.append("element id:" + getId());
		sb.append(", \t");
		sb.append("element name:" + getName());
		sb.append(", \t");
		sb.append("element type:" + getType());
		sb.append(". ");
		return sb.toString();
 
	}

	public void setIdref(String idref) {
		this.idref = idref;
	}

	public String getIdref() {
		return idref;
	}

}
